package net.mingsoft.report_data.dao;

import net.mingsoft.report_data.biz.impl.r.OdFeatureWorkHomeResponse;
import net.mingsoft.report_data.entity.*;
import net.mingsoft.report_data.entity.vo.DateWithCountDto;
import net.mingsoft.report_data.kafka.entity.TravelAreaDto;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author gengfa
 * @date 2022/03/09
 */
public interface ZkDataDao {

    /**
     * 查询常住人口
     * @param beginDate 开始日期
     * @param endDate 结束日期
     * @return 聚合数据
     */
    List<ZkDataPermanentPopulationEntity> selectByPeriod(@Param("beginDate") String beginDate,
                                                         @Param("endDate") String endDate);

    List<DateWithCountDto> selectByPeriodByYear(@Param("beginDate") String beginDate,
                                                         @Param("endDate") String endDate);

    /**
     * 查询流动人口数量
     * @return 查询流动人口
     */
    List<ZkDataFlowPopulationEntity> selectFlowPopulation(@Param("beginDate") String beginDate,
                                                          @Param("endDate") String endDate);

    /**
     * 查询国外人口数量
     * @return 国外人口
     */
    List<ZkDataForeignPopulationEntity> selectForeignPopulation(@Param("beginDate") String beginDate,
                                                                @Param("endDate") String endDate);


    /**
     * 查询国外人口数量
     * @return 国外人口
     */
    List<ZkDataForeignPopulationEntity> selectForeignPopulationByCity(@Param("beginDate") String beginDate,
                                                                      @Param("endDate") String endDate);

    List<ZkDataActivePopulationEntity> selectActivePopulation(@Param("beginDate") String beginDate,
                                                              @Param("endDate") String endDate);

    List<ZkDataMetricEntity> selectMetricByReportType(String type);
    List<ZkDataMetricEntity> selectMetricByIds(List<Long> ids);
    ZkDataMetricEntity selectMetricById(Long id);
    List<ZkDataReportConfigEntity> selectReportConfig(boolean auto);

    ZkDataOdPopulationTimesEntity selectLastOdTimesData(@Param("beginDate") String beginDate,
                                                        @Param("endDate") String endDate);
    ZkDataOdPopulationPeriodEntity selectLastOdPeriodData(@Param("beginDate") String beginDate,
                                                          @Param("endDate") String endDate);

    ZkDataOdPopulationDistanceEntity selectLastOdDistanceData(@Param("beginDate") String beginDate,
                                                              @Param("endDate") String endDate);
    List<ZkDataOdArriveAreaEntity> selectLastOdArriveAreaData(@Param("beginDate") String beginDate,
                                                              @Param("endDate") String endDate);

    List<TravelAreaDto> selectSmugglerArriveArea(@Param("beginDate") String beginDate,
                                                 @Param("endDate") String endDate);
    List<ZkDataSmugglerWorkHomeEntity> selectSmugglerWorkHomeData(@Param("beginDate") String beginDate,
                                                                  @Param("endDate") String endDate);

    List<ZkDataCoastalPopulationWorkHomeEntity> selectCoastalWorkHomeData(@Param("beginDate") String beginDate,
                                                                          @Param("endDate") String endDate);
    List<ZkDataCoastalActiveAreaEntity> selectCoastalActiveAreaData(@Param("beginDate") String beginDate,
                                                                    @Param("endDate") String endDate);
    List<ZkDataPopulationMigrateEntity> selectMigrationData(@Param("beginDate") String beginDate,
                                                            @Param("endDate") String endDate);

    List<ZkDataOdAreaAvgMetricEntity> selectIdAreaAvgData(@Param("beginDate") String beginDate,
                                                          @Param("endDate") String endDate);

    List<ZkDataOdAreaAvgMetricEntity> selectIdAreaAvgAllData(@Param("beginDate") String beginDate,
                                                          @Param("endDate") String endDate);

    List<ZkDataOdFeatureDistanceEntity> selectOdFeatureDistanceData(@Param("beginDate") String beginDate,
                                                                    @Param("endDate") String endDate);
    List<ZkDataOdFeaturePeriodEntity> selectOdFeaturePeriodData(@Param("beginDate") String beginDate,
                                                                @Param("endDate") String endDate);

    List<ZkDataOdFeatureCostTimeEntity> selectOdFeatureCostTimeData(@Param("beginDate") String beginDate,
                                                                    @Param("endDate") String endDate);
    List<ZkDataOdPopulationWorkHomeEntity> selectOdPopulationWorkHomeData(@Param("beginDate") String beginDate,
                                                                          @Param("endDate") String endDate);

    // - 节假日人口流动分析报告节假日人口流动分析报告

    List<ZkDataInIslandFlowPopulationPerDayEntity> selectInIslandFlowPopulationPerData(
            @Param("beginDate") String beginDate, @Param("endDate") String endDate);

    List<DateWithCountDto> selectOutProvinceFlowUser(
            @Param("beginDate") String beginDate, @Param("endDate") String endDate);

    List<DateWithCountDto> selectAbroadFlowUser(
            @Param("beginDate") String beginDate, @Param("endDate") String endDate);

    List<DateWithCountDto> selectTourist(
            @Param("beginDate") String beginDate, @Param("endDate") String endDate);

    List<ZkDataInIslandFlowPopulationPerDayEntity> selectTouristArea(
            @Param("beginDate") String beginDate, @Param("endDate") String endDate);

    List<DateWithCountDto> selectAbroadTourist(
            @Param("beginDate") String beginDate, @Param("endDate") String endDate);

    List<DateWithCountDto> countOutIslandFlowUser(
            @Param("beginDate") String beginDate,
            @Param("endDate") String endDate,
            @Param("flowType") int flowType);

    List<DateWithCountDto> countAbroadFlowUser(
            @Param("beginDate") String beginDate,
            @Param("endDate") String endDate,
            @Param("flowType") int flowType
    );

    List<OdFeatureWorkHomeResponse> getHeatMap(
            @Param("beginDate")String beginDate,
            @Param("endDate") String endDate,
            @Param("limit") Integer limit);

    @Select("select created_date from zk_data_top_heat_area_per_day limit 1")
    String getMinTopHeatAreaPerDayCreatedDate();

    List<String> distinctAreaNames();
    OdFeatureWorkHomeResponse lastAreaResponse(@Param("name") String name);

    List<DateWithCountDto> getHeatMapGroupByDate(
            @Param("beginDate")String beginDate,
            @Param("endDate") String endDate);

    List<DateWithCountDto> getHeatMapGroupByYear(
            @Param("beginDate")String beginDate,
            @Param("endDate") String endDate);


    // 人口动态分析新增
    List<DateWithCountDto> selectDomesticFlowIntoUser(
            @Param("beginDate") String beginDate, @Param("endDate") String endDate, @Param("type") int type);

    List<DateWithCountDto> selectAbroadFlowIntoUser(
            @Param("beginDate") String beginDate, @Param("endDate") String endDate);
}
